package graphing;

import model.Runner;
import parsing.RaceResultParsingInformation;
import utility.Utility;

public class RunnerWithResult {
	private int overallRank ; 
	private int groupRank ; 
	private int sexRank ; 
	private int timeInSeconds ; 
	private Runner person ; 
//	private RaceResult raceResult ; 
	
	public RunnerWithResult(String dataString, RaceResultParsingInformation parsingInformation) {
		if(dataString.length() > parsingInformation.getStateEnd() - 1) {
			this.person = new Runner(dataString, parsingInformation) ; 
			this.groupRank = Utility.getInt(dataString.substring(parsingInformation.getGroupRankStart(), parsingInformation.getGroupRankEnd()).trim()) ;
			this.overallRank = Utility.getInt(dataString.substring(parsingInformation.getOverallRankStart(), parsingInformation.getOverallRankEnd()).trim()) ;
			this.sexRank = Utility.getInt(dataString.substring(parsingInformation.getSexRankStart(), parsingInformation.getSexRankEnd()).trim()) ;
			this.timeInSeconds = Utility.computeTimeInSeconds(dataString.substring(parsingInformation.getTimeStart(), parsingInformation.getTimeEnd()).trim()) ;
		}
		else {
			System.out.println("invalid string: " + dataString) ;
		}
	}

	public String getName() {
		return this.person.getName() ;
	}

	public int getOverallRank() {
		return overallRank;
	}

	public int getGroupRank() {
		return groupRank;
	}

	public int getAge(int currentYear) {
		return this.person.getAge(currentYear) ;
	}

	public boolean isMale() {
		return this.person.isMale() ;
	}

	public int getSexRank() {
		return sexRank;
	}

	public String getTown() {
		return this.person.getTown() ;
	}

	public String getState() {
		return this.person.getState() ;
	}

	public int getTimeInSeconds() {
		return timeInSeconds;
	}
	
	public Runner getPerson() {
		return this.person ;
	}
}
